const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production' ? '././' : '/',
  assetsDir: 'static',
  devServer: {
    proxy: {
      '/API/local/*': {
        target: 'http://localhost:7001/',
        changeOrigin: true,
        pathRewrite: {
          '^/API/local/': ''
        },
        secure: false
      }
    }
  },
  productionSourceMap: false,
  chainWebpack: config => {
    config.module
      .rule('iview')
      .test(/iview.src.*?js/)
      .use('babel')
      .loader('babel-loader')
      .end();
    config.resolve.alias
      .set('@', resolve('src'))
      .set('assets', resolve('src/assets'))
      .set('scss', resolve('src/assets/scss'))
      .set('css', resolve('src/assets/css'))
      .set('components', resolve('src/components'));
  }
};
